<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<title>Insert title here</title>
	<script type="text/javascript" src="js/ajax.js"></script>
	<script type="text/javascript">
		function check_name() {
			var xhr = getXhr();
			
			xhr.open("post", "/ajax01/check_name2.do", true);
			xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded'); 
			xhr.onreadystatechange = function() {
				if(xhr.readyState == 4 && xhr.status == 200) {
					var txt = xhr.responseText;
					$("info").innerHTML = txt;
				}
			}; 
			xhr.send("name=" + $F("username"));
		}
	</script>
</head>
<body style="font-size:30px;">
	<form action="#" method="post">
		用户名：<input id="username" name="username" type="text" onblur="check_name();" />
		<span id="info"></span>
		<br />
		密&nbsp;&nbsp;&nbsp;码：<input id="password" name="password" type="password" />
		<br />
		<input type="submit" value="注册" />
	</form>
</body>
</html>